#pragma once
#include <iostream>
#include <pthread.h>
class myMutex{
public:
    myMutex(pthread_mutex_t* lock_p):lock_p_(lock_p)
    {
    }
    void Lock()
    {
       if(lock_p_) pthread_mutex_lock(lock_p_);
    }
    void unlock()
    {
        if(lock_p_) pthread_mutex_unlock(lock_p_);
    }

    ~myMutex()
    {
    }

private:
    pthread_mutex_t* lock_p_;
};

class MutexGuard{
    public:
        MutexGuard(pthread_mutex_t *mutex):mutex_(mutex)
        {
            mutex_.Lock();
        }

        ~MutexGuard()
        {
            mutex_.unlock();
        }
    public:
        myMutex mutex_;
};